package com.bluegalaxy.nhb.snapi.core.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * Created by IntelliJ IDEA.
 * @description: To change this template use File | Settings | File Templates.
 */
@Configuration
public class MyErrorPageRegistar implements ErrorPageRegistrar {

    /**
     * 错误页面拦截
     *
     * @param errorPageRegistry
     */
    @Override
    public void registerErrorPages(ErrorPageRegistry errorPageRegistry) {
        errorPageRegistry.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/error404"));
        errorPageRegistry.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error500"));
        errorPageRegistry.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/error400"));
        errorPageRegistry.addErrorPages(new ErrorPage(HttpStatus.METHOD_NOT_ALLOWED, "/error405"));
    }

}
